/**
 * 
 */
package com.module.osr.stormbringer.bus;

import com.dalonedrau.d20.Diceroller;
import com.module.stormbringer.globals.Globals;

/**
 * @author Donald
 *
 */
public final class Money {
	/**
	 * Converts the value of money of one type into that of another.
	 * @param type1 the first type
	 * @param type2 the second type
	 * @param amount the amount of money of the first type
	 * @return <code>float</code>
	 */
	public float convertMoney(final int type1, final int type2, 
			final float amount) {
		float newAmount = amount;		
		if (type1 < type2) { // going from lower to higher
			for (int i = type1; i < type2; i++) {
				newAmount *= Globals.COIN_CONVERSION_SMALL_2_LARGE[i];
			}
		} else if (type1 > type2) { // going from higher to lower
			for (int i = type1; i > type2; i--) {
				newAmount *= Globals.COIN_CONVERSION_LARGE_2_SMALL[i];
			}			
		}
		return newAmount;
	}
	public Jewel createJewel(final int type) {
		// set the carets - DO THIS RANDOM
		int c = 20;
		Jewel jewel = new Jewel(c, type);
		// check for flaw
		if (Diceroller.getInstance().rolldX(6) <= 4) {
			// FLAWED
			switch (Diceroller.getInstance().rolldXPlusY(4, -1)) {
			case 0:
				jewel.setFlaw(0f);
				break;
			case 1:
				jewel.setFlaw(0.25f);
				break;
			case 2:
				jewel.setFlaw(0.5f);
				break;
			default:
				jewel.setFlaw(0.75f);
				break;
			}
		}
		return jewel;
	}
}
